package com.lex.common.factory;

import jakarta.annotation.PreDestroy;
import org.springframework.stereotype.Component;

/**
 * 在应用退出之前会关闭后台异步任务线程
 */
@Component
public class ShutDownManager {
    @PreDestroy
    public void destroy() {
        shutdownAsyncManager();
    }

    private void shutdownAsyncManager() {
        try {
            System.out.println("====关闭后台任务任务线程池====");
            AsyncManager.factory().shutdown();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
